/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package DG.impl;

import DG.Clazz;
import DG.DGPackage;
import DG.Operation;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Clazz</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link DG.impl.ClazzImpl#getOps <em>Ops</em>}</li>
 *   <li>{@link DG.impl.ClazzImpl#getSuper <em>Super</em>}</li>
 *   <li>{@link DG.impl.ClazzImpl#getNom <em>Nom</em>}</li>
 *   <li>{@link DG.impl.ClazzImpl#getRefclass <em>Refclass</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ClazzImpl extends EObjectImpl implements Clazz {
	/**
	 * The cached value of the '{@link #getOps() <em>Ops</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOps()
	 * @generated
	 * @ordered
	 */
	protected EList<Operation> ops;

	/**
	 * The cached value of the '{@link #getSuper() <em>Super</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSuper()
	 * @generated
	 * @ordered
	 */
	protected Clazz super_;

	/**
	 * The default value of the '{@link #getNom() <em>Nom</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNom()
	 * @generated
	 * @ordered
	 */
	protected static final String NOM_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getNom() <em>Nom</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNom()
	 * @generated
	 * @ordered
	 */
	protected String nom = NOM_EDEFAULT;

	/**
	 * The cached value of the '{@link #getRefclass() <em>Refclass</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRefclass()
	 * @generated
	 * @ordered
	 */
	protected Clazz refclass;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ClazzImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DGPackage.Literals.CLAZZ;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Operation> getOps() {
		if (ops == null) {
			ops = new EObjectResolvingEList<Operation>(Operation.class, this, DGPackage.CLAZZ__OPS);
		}
		return ops;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Clazz getSuper() {
		if (super_ != null && super_.eIsProxy()) {
			InternalEObject oldSuper = (InternalEObject)super_;
			super_ = (Clazz)eResolveProxy(oldSuper);
			if (super_ != oldSuper) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, DGPackage.CLAZZ__SUPER, oldSuper, super_));
			}
		}
		return super_;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Clazz basicGetSuper() {
		return super_;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSuper(Clazz newSuper) {
		Clazz oldSuper = super_;
		super_ = newSuper;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DGPackage.CLAZZ__SUPER, oldSuper, super_));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getNom() {
		return nom;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNom(String newNom) {
		String oldNom = nom;
		nom = newNom;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DGPackage.CLAZZ__NOM, oldNom, nom));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Clazz getRefclass() {
		if (refclass != null && refclass.eIsProxy()) {
			InternalEObject oldRefclass = (InternalEObject)refclass;
			refclass = (Clazz)eResolveProxy(oldRefclass);
			if (refclass != oldRefclass) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, DGPackage.CLAZZ__REFCLASS, oldRefclass, refclass));
			}
		}
		return refclass;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Clazz basicGetRefclass() {
		return refclass;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRefclass(Clazz newRefclass) {
		Clazz oldRefclass = refclass;
		refclass = newRefclass;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DGPackage.CLAZZ__REFCLASS, oldRefclass, refclass));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DGPackage.CLAZZ__OPS:
				return getOps();
			case DGPackage.CLAZZ__SUPER:
				if (resolve) return getSuper();
				return basicGetSuper();
			case DGPackage.CLAZZ__NOM:
				return getNom();
			case DGPackage.CLAZZ__REFCLASS:
				if (resolve) return getRefclass();
				return basicGetRefclass();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DGPackage.CLAZZ__OPS:
				getOps().clear();
				getOps().addAll((Collection<? extends Operation>)newValue);
				return;
			case DGPackage.CLAZZ__SUPER:
				setSuper((Clazz)newValue);
				return;
			case DGPackage.CLAZZ__NOM:
				setNom((String)newValue);
				return;
			case DGPackage.CLAZZ__REFCLASS:
				setRefclass((Clazz)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DGPackage.CLAZZ__OPS:
				getOps().clear();
				return;
			case DGPackage.CLAZZ__SUPER:
				setSuper((Clazz)null);
				return;
			case DGPackage.CLAZZ__NOM:
				setNom(NOM_EDEFAULT);
				return;
			case DGPackage.CLAZZ__REFCLASS:
				setRefclass((Clazz)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DGPackage.CLAZZ__OPS:
				return ops != null && !ops.isEmpty();
			case DGPackage.CLAZZ__SUPER:
				return super_ != null;
			case DGPackage.CLAZZ__NOM:
				return NOM_EDEFAULT == null ? nom != null : !NOM_EDEFAULT.equals(nom);
			case DGPackage.CLAZZ__REFCLASS:
				return refclass != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (nom: ");
		result.append(nom);
		result.append(')');
		return result.toString();
	}

} //ClazzImpl
